import { find } from 'lodash';

export const getTableColumns = (
	{ params, orgList, locationTypeList, areaTypeList }: 
	{ params :any, orgList:any, locationTypeList: any, areaTypeList: any }
) => [
	{
		title: "月台ID",
		dataIndex: "id",
		width: 140,
		ellipsis: true
	},
	{
		title: "月台名称",
		dataIndex: "scName",
		width: 140,
		ellipsis: true
	},
	{
		title: "月台类型",
		dataIndex: "type",
		width: 140,
		ellipsis: true,
		render: (_: any, record: any) => {
			const result = find(areaTypeList?.data || [], (item: any) => item.value === record.type)
			return (
				<span>
					{result?.label}
				</span>
			)
		}
	},
	{
		title: "所属组织",
		dataIndex: "createOrgId",
		width: 140,
		ellipsis: true,
		render: (_: any, record: any) => {
			const result = find(orgList?.data || [], (item: any) => item.id === record.createOrgId)
			return (
				<span>
					{result?.name}
				</span>
			)
		}
	},
	{
		title: "坐标系",
		dataIndex: "coordinate",
		width: 100,
		ellipsis: true,
		render: (_: any, record: any) => {
			const result = find(locationTypeList?.data || [], (item: any) => item.value === record.coordinate)
			return (
				<span>
					{result?.label}
				</span>
			)
		}
	},
	{
		title: "接驳点数量",
		dataIndex: "siteCount",
		width: 100,
		ellipsis: true,
	},
	{
		title: "创建日期",
		dataIndex: "createTime",
		width: 140,
		ellipsis: true
	},
];

export const USER_STATUS = [
	{ label: '在线', value: 1 },
	{ label: '离线', value: 2 }
]

export const getSearchColumns = ({areaTypeList, orgList}: any) => [
	{
		type: "input",
		placeholder: "月台名称",
		name: "scName"
	},
	{
		type: "select",
		placeholder: "月台类型",
		name: "type",
		options: areaTypeList?.data || [],
	},
	{
		type: "select",
		placeholder: "所属组织",
		name: "createOrgId",
		options: orgList?.data || [],
		fieldProps:{
			fieldNames: {
				label: 'name',  // 显示文本对应的字段
				value: 'id',    // 值对应的字段
			}
		}
	}
]